const express = require('express');
const bodyParser = require('body-parser');
const {host,port} = require('./config.json')
// 创建 application/x-www-form-urlencoded 编码解析
var urlencodedParser = bodyParser.urlencoded({extended:false});

//引入所有路由
let allRouter= require("./router/index");

//创建服务器
const app = express();
app.use(bodyParser.json());//转json数据 {"key1":"value1","key2":"value2"}
app.use(urlencodedParser);//转键值对 key1=value1&key2=value2
//使用路由
app.use(allRouter);

//监听端口
app.listen(port, () => {
    console.log(`服务器已开启，请连接${host}`);
})